﻿using AmiDraw.Editor.Factory;
using AmiDraw.Editor.Model;
using AmiDraw.Editor.ViewModel;
using AmiDraw.Lib;
using Microsoft.Win32;
using Panuon.UI.Core;
using PropertyChanged;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace AmiDraw.Editor.View.Dialog
{
    /// <summary>
    /// CardInfoDialog.xaml 的交互逻辑
    /// </summary>
    public partial class CardInfoDialog : Window
    {


        public CardInfoDialog(ObservableCard card)
        {
            InitializeComponent();
            ViewModel.ObservableCard = card;
        }

        private void Button_Ok(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
            this.Close();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            this.Close();

        }

        private void Button_Click_Delete(object sender, RoutedEventArgs e)
        {
            this.ViewModel.ObservableCard = null;
            DialogResult = true;
            this.Close();
        }
    }
    [AddINotifyPropertyChangedInterface]
    public class CardInfoDialogViewModel
    {
        public ObservableCard ObservableCard { get; set; }

        public ICommand ImportImageCommand { get; set; }

        public CardInfoDialogViewModel()
        {
            ImportImageCommand = new RelayCommand(importImage);
        }

        private void importImage (object obj)
        {
            if(CommonOperateHelper.ImportImage(null,out var file))
            {
                this.ObservableCard.ImageResKey = Path.GetFileName(file);

            }
        }



    }
}
